package com.mall.web.util;


import org.apache.commons.lang3.StringUtils;


public class SplitUtil {

	public static String convertStrToArray(String str, int a) {

		if (StringUtils.isBlank(str)) {
			return "";
		}

		String[] strs = str.split("\\,");
		if (strs.length < a) {
			return "";
		}

		try {
			if (StringUtils.isBlank(str)) {
				return "";
			}
			String[] strArray = null;
			strArray = str.split("\\,"); // 拆分字符为"," ,然后把结果交给数组strArray
			String ss = strArray[a];
			return ss;
		} catch (Exception e) {
		}
		return "";

	}
	
	
	//民宿获取除展示外的配套个数
		public static int assortLength(String str, int a) {

			if (StringUtils.isBlank(str)) {
				return 0;
			}

			String[] strs = str.split("\\,");
			if (strs.length <= a) {
				return 0;
			}

			try {
				if (StringUtils.isBlank(str)) {
					return 0;
				}
				String[] strArray = null;
				strArray = str.split("\\,"); // 拆分字符为"," ,然后把结果交给数组strArray
				int length = strArray.length-a;
				return length;
			} catch (Exception e) {
			}
			return 0;

		}
		
		//获得标签个数
		public static int biaoqianLength(String str) {
			try {
				if (StringUtils.isBlank(str)) {
					return 0;
				}
				String[] strArray = null;
				strArray = str.split("\\,"); // 拆分字符为"," ,然后把结果交给数组strArray
				int length = strArray.length;
				return length;
			} catch (Exception e) {
			}
			return 0;

		}
		
		//银行卡号按四位一显示
		public static String getAccountCardByLen(String accountCard,int len){
			if (StringUtils.isBlank(accountCard)) {
				return "";
			}
			
			StringBuilder sb=new StringBuilder(accountCard);
            int length = accountCard.length()/len+accountCard.length();
            for(int i=0;i<length;i++){
                    if(i%5==0){
                            sb.insert(i," ");
                    }
            }
            sb.deleteCharAt(0);
            return sb.toString();
		}
		
}
